import 'package:flutter/material.dart';
import 'package:aio/aio.dart';
import 'package:app/src/manager/audit_manager.dart';
import 'package:app/src/presenter/review_presenter.dart';
import 'package:app/src/ui/app_ui.dart';
import 'package:app/src/ui/route/works/public/image/ui_image_upload.dart';

import '../../../../../generated/app_strings.dart';

///审核详情页通用UI
class ReviewDetailsUi {
  static Widget build(BuildContext context, ReviewPresenter presenter,
      ResponseCallbackWithUi ui,
      {String? title = null, Widget? bottoUi}) {
    px.init(context);
    var scaffold = AppUi.getScaffoldWithReView(
        context,
        _body(context, presenter, ui),
        AuditManager.getAuditManager().item,
        null,
        null,
        title: title,
        bottoUi: bottoUi);
    return WillPopScope(
      child: scaffold,
      onWillPop: () async {
        UiImageUpLoad.clear(); //图片清空
        return true; //true 不屏蔽返回键
      },
    );
  }

  static Widget _body(BuildContext context, ReviewPresenter presenter,
      ResponseCallbackWithUi ui) {
    return StatefulBuilder(
        builder: (BuildContext context, StateSetter setState) {
      presenter.setStateBody = setState;
      // if (presenter?.mDatas == null && !presenter.isLoad) {
      //   //fixme 重新刷新
      //   var button = AppUi.materialButton(AppStrings.of(context).refresh2,
      //       onPressed: () {
      //     presenter?.getContractapplygetinfo(context, callback: () {
      //       setState(() {});
      //     });
      //     setState(() {});
      //   });
      //   return Center(
      //     child: button,
      //   );
      // }
      return ui(context);
    });
  }
}
